package com.chagee.store.operation.server.facade;

import com.chagee.base.utils.PaginationData;
import com.chagee.base.utils.PaginationRequest;
import com.chagee.payment.sdk.utils.AjaxResult;
import com.chagee.store.operation.api.request.*;
import com.chagee.store.operation.api.response.SettlementResponse;
import com.chagee.store.operation.api.response.WorkOrderResponse;
import com.chagee.store.operation.server.model.param.CreateTradeOrderParam;
import com.chagee.store.operation.server.model.vo.PaymentResultVO;
import com.chagee.store.operation.server.service.biz.PaymentBizService;
import com.chagee.store.operation.server.service.biz.StoreAppSettlementBizService;
import com.chagee.store.operation.server.service.biz.StoreSettlementBizService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 打烊结算
 * @Author : hk
 * @Date : 2024/10/14
 */

@Slf4j
@Service
@RequiredArgsConstructor
public class StoreAppSettlementFacade {

	@Resource
	private StoreAppSettlementBizService storeAppSettlementBizService;

	@Resource
	private PaymentBizService paymentBizService;

	/**
	 * 结算单列表/查询
	 */
	public PaginationData<SettlementResponse> query(PaginationRequest<SettlementAppRequest> request){
		return storeAppSettlementBizService.querySettlementPage(request);
	}

	/**
	 * 结算单详情
	 */
	public SettlementResponse queryDetail(SettlementAppOrderDetailRequest request){
		return storeAppSettlementBizService.queryDetail(request);
	}

	/**
	 * 结算单工单详情
	 */
	public PaginationData<WorkOrderResponse> queryOrderList(PaginationRequest<SettlementAppOrderDetailRequest> request){
		return storeAppSettlementBizService.queryOrderList(request);
	}

	public Boolean collate(SettlementCollateRequest request){
		return storeAppSettlementBizService.collate(request);
	}

	public PaymentResultVO preSubmitOrder(CreateTradeOrderParam createTradeOrderReqDto) {
		return paymentBizService.createOrder(createTradeOrderReqDto);
	}

	/**
	 * 支付罚金后修改结算单状态的回调接口
	 *
	 * @param httpServletRequest 回调入参
	 * @return 回调出参
	 */
	public String payNoticeCallback(HttpServletRequest httpServletRequest) throws Exception {
		return storeAppSettlementBizService.payNoticeCallback(httpServletRequest);
	}

	public Boolean rejected(SettlementRejectedRequest request){
		return storeAppSettlementBizService.rejected(request);
	}

}
